//
//  CommonMacro.swift
//  Swift-app开发基础架构
//
//  Created by pro on 2017/8/14.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

import UIKit

/*
 MARK: 宏定义
 */
// 字体
func kFont(_ fontSize: CGFloat) -> UIFont {
    
    let font = UIFont.systemFont(ofSize: fontSize)
    return font
}

// 颜色
func kRgba(_ red: CGFloat, _ green: CGFloat, _ blue: CGFloat, _ alpha: CGFloat) -> UIColor {
    return UIColor(red: red/255.0, green: green/255.0, blue: blue/255.0, alpha: alpha)
}

/*
 常用
 */
typealias KZBlock = () -> ()

/*
 MARK: 宏常量
 */
// 屏幕宽高
let kScreenWidth: CGFloat = UIScreen.main.bounds.size.width
let kScreenHeight: CGFloat = UIScreen.main.bounds.size.height


func H(_ height: CGFloat) -> CGFloat {
    return height / 667.0 * kScreenHeight
}
func W(_ width: CGFloat) -> CGFloat {
    return width / 375.0 * kScreenWidth
}


// appdelegate
let kAppDelegate: AppDelegate? = UIApplication.shared.delegate as? AppDelegate
let kWindow: UIWindow = (kAppDelegate?.window)!

// 主题色
let kThemeColor = UIColor.init(hexColor: "FB5970")          // 粉红色
let kGreenColor = kRgba(165, 194, 96, 1)                    // 草绿色
let kBgColor = UIColor.init(white: 0.95, alpha: 1)          // 淡灰色
let kLineColor = UIColor.init(white: 0.88, alpha: 1)        // 灰色
let kLineDarkColor = UIColor.init(white: 0.8, alpha: 1)     // 灰色
let kRedColor = UIColor.init(hexColor: "d81e06")
let kBlueColor = UIColor.init(hexColor: "1296db")
let kBlueDarkColor = kRgba(71, 111, 128, 1)
let kYellowColor = kRgba(247, 208, 95, 1)
let kOrangeColor = kRgba(206, 89, 36, 1)

// 网络
let kBaseURL = "https://api.91renta.com/public/index.php"

// key
let kTB_APPKEY: String = "24942009"

// 图片
let kDefaultImage = #imageLiteral(resourceName: "默认头像")


// 判断设备
var kIsIPhoneX: Bool {
    if let currentMode = UIScreen.main.currentMode {
        return currentMode.size.equalTo(CGSize(width: 1125, height: 2436))
    } else {
        return false
    }
}

// 用户
var kUser: KZUserModel! = nil
var kUserDic: [String: Any] = [:] {
    didSet {
        kUser = try? KZUserModel.model(from: kUserDic) 
    }
}


